<?php
require_once "Common/database.php";
require_once "Common/values.php";



echo '<h3>Overdue jobs</h3>';
$overduetotal=0;
$overdue = date("Y-m-d");
$overdue = strtotime(date("Y-m-d", strtotime($overdue)) . "Today");
$overdue = date("Y-m-d",$overdue);
list($day, $month, $year,$spare) = preg_split('[/]', $overdue);
$overduedate=$year.'-'.$month.'-'.$day;
$overduedate=$year.''.$month.''.$day;
#echo $overduedate.'<br>';
$overduedate=strtotime($overduedate);
#echo $overduedate.'<br><br>';

$query1=mysql_query("SELECT * FROM tbljobs WHERE Closed='' AND Project='Helpdesk'");
while($row = mysql_fetch_array($query1))
{
list($day, $month, $year,$spare) = preg_split('[/]', $row[Due]);
$jobdate='20'.$year.'-'.$month.'-'.$day;
#echo $jobdate.'<br>';
$jobdate=strtotime($jobdate);
#echo $jobdate.'<br>';
if($jobdate<$overduedate)
 {
 
 $overduetotal++;
 }

}
#echo '<b>Returned '.$overduetotal.'</b><br>';
$query1=mysql_query("SELECT * FROM tbljobs WHERE Closed='' AND Project='Helpdesk'");
echo '<center><table><tr>';


colourkey();


echo '<b>'.$overduetotal.' Jobs overdue</b>';


echo '<FORM action="index.php?m=h&p=hfilter&f=helpdesk" method="POST">';
echo '<TABLE width="100%" valign="top" Border=1 >';
echo '<tr bgcolor="'.$colourtoprow.'"><td>Log Number</td><td>Due
</td><td>Assigned <br>to</td><td>Requestor</td><td>Subject</td><td>Proirty</td><td>Status</td></tr>';


while($row = mysql_fetch_array($query1))
{
list($day, $month, $year,$spare) = preg_split('[/]', $row[Due]);
$jobdate='20'.$year.'-'.$month.'-'.$day;
#echo $jobdate.'<br>';
$jobdate=strtotime($jobdate);
#echo $jobdate.'<br>';

if($jobdate<$overduedate)
 {

if($row[Closed]=='checked')
{
$row[Closed]='Closed';
}
else
{
$row[Closed]='Open';
}
  echo '
<tr ';
colourjobs();
echo 'id="row'.$i.'" onMouseOver="row'.$i.'.style.backgroundColor=\''.$colourselector.'\';" onmouseout="row'.$i.'.style.backgroundColor=\''.$colour.'\';" onclick="location.href=\'index.php?f=helpdesk&p=hupdate&log='.$row['LogNumber'] .' \'">
<td>'.$row['LogNumber']. "</td><td>" . $row['Due'].'</td>'.'<td>'.$row[Assigned].'</td><td>'.$row['Requestor'].'</td><td>'.$row[Subject].'</td>'.'<td>'.$row[Proirty].'</td>'.'<td>'.$row[Status].'</td></tr>';
  $i=$i+1;
 }

}
echo '</TABLE> </FORM>';
?>
